package com.example.net;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
import android.view.View;

import com.example.entity.CircleShareEntity;
import com.example.entity.ShareEntity;
import com.example.huashangapp.HSApplication;
import com.example.huashangapp.R;
import com.example.service.MainService;
import com.example.ui.FindPassword1Activity;
import com.example.ui.FindPassword2Activity;
import com.example.ui.LoginActivity;
import com.example.ui.Userdata;
import com.example.ui.homepage.HomePageView;
import com.example.ui.homepage.MyInformationActivity;
import com.example.ui.homepage.SetHeadActivity;
import com.example.ui.homepage.SetHomePageWallActivity;
import com.example.ui.learn.DownUtils;
import com.example.ui.leftmenu.Item05View;
import com.example.ui.leftmenu.LeftMenuView;
import com.example.ui.share.CircleHomeActivity;
import com.example.ui.share.CircleShareContentActivity;
import com.example.ui.share.HomePageShareContentActivity;
import com.example.ui.share.PublishCircleShareActivity;
import com.example.ui.share.PublishShareActivity;
import com.example.ui.share.ShareContentActivity;
import com.example.util.AsyncLoadImage;
import com.example.util.BitmapLoad;
import com.example.util.CallBack;
import com.example.util.Util;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;

public class Communication {

	private static AsyncHttpClient client;
	private static RequestParams params;
	private static SharedPreferences sp=HSApplication.sp;
	private static Editor spEditor=sp.edit();
	public static String POI ="http://192.168.1.104:80";//接口前缀
	public static String POINT="http://112.124.0.70:8088";//数据库前缀 华商http://112.124.0.70:8088  "http://http://192.168.1.101:8080";// 
	// public static String POINT = "http://192.168.1.138:8080";//雷
	// public static String POINT = "http://192.168.1.132:8099";//高

	public static String BASEURL = POI + "/huashangService";
	// 登录
	private static String LOGIN = BASEURL + "/login";
	// 忘记密码
	private static String FORGET_PASSWORD = BASEURL + "/senddata";  
	// 验证新密码
	private static String CHECK_NEW_PASSWORD = BASEURL + "/reset";
	// 0、查询个人的分享、赞、收藏 的数量
	private static String GET_STATISTICS_NUMBER = BASEURL   
			+ "/getStatisticsNumber";
	// 1、上传用户头像
	private static String UPLOAD_HEAD = BASEURL + "/uploadHeadPortrait";
	// 2、上传用户个人照片墙
	private static String UPLOAD_WALL = BASEURL + "/uploadPersonalPhotoWall";
	// 3、获取用户个人照片墙照片
	private static String GET_WALL = BASEURL + "/inquiryPersonalPhotoWall";
	// 4、根据照片墙id替换照片
	// 5、根据用户id查询用户头像
	private static String GET_HEAD = BASEURL + "/inquiryHeadPortrait";
	// 6、删除用户头像
	// 7、删除照片墙的图片
	private static String DELETE_WALL = BASEURL + "/deletePhotoWallPic";
	// 8、查询用户个人资料
	private static String QUERY_USER = BASEURL + "/inquiryMyMaterial";
	// 9、修改用户个人资料
	private static String UPDATE_USER = BASEURL + "/renewMyMaterial";
	// 10、根据用户id查询用户最新的个性签名
	private static String GET_SIGNATURE = BASEURL + "/getSignature";
	// 11、更新用户的个性签名
	private static String UPDATE_SIGNATURE = BASEURL + "/updateSignature";
	// 12、根据用户id查询该用户所有分享
	private static String GET_MY_SHARE = BASEURL + "/lookShareById";
	// 13、赞过的人
	private static String GET_PRAISE_PERSON = BASEURL
			+ "/queryAlreadyPraiseByBlogId";
	// 14、根据指定分享id查询相应的评论及回复
	private static String LOOK_COMMENT = BASEURL + "/lookCommentById";
	// 14-1、根据指定分享id查询相应的评论及回复(13、14 合二为一)
	// private static String LOOK_COMMENT_AND_PRAISE =
	// BASEURL+"/lookCommentAndPraise";
	// 15、增加回复
	private static String ADD_REPLY = BASEURL + "/addReply";
	// 16、最新分享（最新推荐）-----乐分享（最新分享）
	private static String GET_NEW_SHARE = BASEURL + "/lookNewestShare";
	// 17、增加赞
	private static String ADD_PRAISE = BASEURL + "/addPraise";
	// 18、增加评论
	private static String ADD_COMMENT = BASEURL + "/addComment";
	// 19、上传用户发表分享的图片
	private static String UPLOAD_SHARE_PICTURE = BASEURL
			+ "/uploadSharePicAction";
	// 20、删除上传用户发表分享的图片
	private static String DELETE_SHARE_PICTURE = BASEURL
			+ "/deleteSharePicAction";
	// 21、增加原创分享
	private static String ADD_SHARE = BASEURL + "/addShare";
	// 22、增加推荐2级
	private static String ADD_FORWARD_SHARE2 = BASEURL + "/addShare2";// 增加推荐2级
	// 23、增加推荐3级
	private static String ADD_FORWARD_SHARE3 = BASEURL + "/addShare3";// 增加推荐3级
	// 24、查询圈子分享
	private static String SELECT_CIRCLE_SHARE = BASEURL + "/queryCircleShare";
	// 25、增加圈子分享
	private static String ADD_CIRCLE_SHARE = BASEURL + "/addCircleShare";
	// 26、根据指定分享id查询相应的 圈子的 评论及回复
	private static String LOOK_CIRCLE_COMMENT = BASEURL + "/lookCommentAndPraise";
	// 27、申请加入圈子
	private static String WAIT_JOIN_CIRCLE = BASEURL + "/waitJoin";

	// 登陆
	public static void login(String mobile, String pwd, final CallBack callBack) {
		String pushid = "1";// Leone add 1代表Android客户端2表示ios登陆
		String userId = HSApplication.getInstance().getSpUtil().getUserId();
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("mobile", mobile);
		params.put("pwd", pwd);
		params.put("TokenType", pushid);
		params.put("Token", userId);
		Log.i("....", mobile + "/" + pwd + "/" + pushid + "/" + userId+params);
		client.setTimeout(10000);
		client.post(LOGIN, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					if ("true".equals(str)) {
						ArrayList<Userdata> la_ud = new ArrayList<Userdata>();
						String userinfo = new JSONObject(response.toString())
						.getString("response1").trim().toString();
						la_ud = AnalyzingJson.getdata_login(userinfo);
						getHead(la_ud.get(0).getUserId());
						callBack.run(true,"true");
					}else if("false".equals(str)){
						callBack.run(true,"false");
					}else if("mobile".equals(str)||"pwd".equals(str)){
						callBack.run(false,"faile");
					}else  if("error".equals(str)){
						callBack.run(false,"error");
					}
				} catch (JSONException e) {
					callBack.run(false,"json");
					e.printStackTrace();
				}
			}
			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				callBack.run(false,"errorResponse");
			}
		});
	}

	// 忘记密码
	public static void forgetPassword(String tel) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("mobile", tel);
		client.post(FORGET_PASSWORD, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					if (str.equals("success")) {
						FindPassword1Activity.handler
								.sendEmptyMessage(FindPassword1Activity.SUCCESS);
					} else {
						FindPassword1Activity.handler
								.sendEmptyMessage(FindPassword1Activity.FAIL);
					}
				} catch (JSONException e) {
					FindPassword1Activity.handler
							.sendEmptyMessage(FindPassword1Activity.NONE);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				FindPassword1Activity.handler
						.sendEmptyMessage(FindPassword1Activity.FAIL);
				super.onFailure(e, errorResponse);
			}
		});
	}
	// 验证新密码
	public static void checkNewPassword(String tel, String code) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("mobile", tel);
		params.put("code", code);
		client.post(CHECK_NEW_PASSWORD, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					if (str.equals("success")) {
						FindPassword2Activity.handler
								.sendEmptyMessage(FindPassword2Activity.SUCCESS);
					}
				} catch (JSONException e) {
					FindPassword2Activity.handler
							.sendEmptyMessage(FindPassword2Activity.NONE);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				FindPassword2Activity.handler
						.sendEmptyMessage(FindPassword2Activity.FAIL);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 0、查询个人的分享、赞、收藏 的数量
	public static void getStatisticsNumber(String uid) {
		
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("userid", uid);
		client.post(GET_STATISTICS_NUMBER, params,
				new JsonHttpResponseHandler() {
					@Override
					public void onSuccess(int statusCode, JSONObject response) {
						try {
							// String str = new
							// JSONObject(response.toString()).getString("response").trim().toString();
							JSONObject jsonObject = new JSONObject(response
									.toString()).getJSONObject("response");
							LeftMenuView.shareNum.setText(jsonObject.getString(
									"share").toString());
							LeftMenuView.praiseNum.setText(jsonObject
									.getString("praise").toString());
							LeftMenuView.collectNum.setText(jsonObject
									.getString("keep").toString());
							HomePageView.handler.sendEmptyMessage(4);
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					@Override
					public void onFailure(Throwable e, JSONObject errorResponse) {
						HomePageView.handler.sendEmptyMessage(1);
						super.onFailure(e, errorResponse);
					}
				});
	}

	// 1、上传头像
	public static void uploadHead(final Context context, final String uid,
			final String imgPath) {
		try {
			client = new AsyncHttpClient();
			params = new RequestParams();
			params.put("uid", uid);
			params.put("upload", new File(imgPath));
			Log.i("pic","上传的图片"+imgPath);
			client.post(UPLOAD_HEAD, params, new JsonHttpResponseHandler() {
				@Override
				public void onSuccess(int statusCode, JSONObject response) {
					try {
						String str = new JSONObject(response.toString())
								.getString("response").trim().toString();
						if (str.equals("true")) {
							SetHeadActivity.handler.sendEmptyMessage(0);
						}
					} catch (JSONException e) {
						SetHeadActivity.handler.sendEmptyMessage(1);
						e.printStackTrace();
					}
					super.onSuccess(statusCode, response);
				}

				@Override
				public void onFailure(Throwable e, JSONObject errorResponse) {
					SetHeadActivity.handler.sendEmptyMessage(1);
					super.onFailure(e, errorResponse);
				}
			});
		} catch (FileNotFoundException e) {
			SetHeadActivity.handler.sendEmptyMessage(2);
			e.printStackTrace();
		}
	}

	// 2、上传用户个人照片墙
	public static void uploadHomepagewall(final Context context,
			final String uid, final String imgPath) {
		try {
			client = new AsyncHttpClient();
			params = new RequestParams();
			params.put("uid", uid);
			params.put("upload", new File(imgPath));
			client.post(UPLOAD_WALL, params, new JsonHttpResponseHandler() {
				@Override
				public void onSuccess(int statusCode, JSONObject response) {
					try {
						String str = new JSONObject(response.toString())
								.getString("response").trim().toString();
						HomePageView.imgWallList.add(Util.getMap(str));
						SetHomePageWallActivity.handler.sendEmptyMessage(0);
					} catch (JSONException e) {
						SetHomePageWallActivity.handler.sendEmptyMessage(1);
						e.printStackTrace();
					}
					super.onSuccess(statusCode, response);
				}

				@Override
				public void onFailure(Throwable e, JSONObject errorResponse) {
					SetHomePageWallActivity.handler.sendEmptyMessage(1);
					super.onFailure(e, errorResponse);
				}
			});
		} catch (FileNotFoundException e) {
			SetHomePageWallActivity.handler.sendEmptyMessage(2);
			e.printStackTrace();
		}
	}

	// 3、获取个人照片墙照片
	public static void getHomepageWall(final Context context, String uid) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		client.post(GET_WALL, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					if (str != null) {
						JSONArray jsonArray = new JSONArray(str);
						HomePageView.imgWallList = new ArrayList<Map<String, Object>>();
						for (int i = 0; i < jsonArray.length(); i++) {
							JSONObject jsonObject = jsonArray.getJSONObject(i);
							HomePageView.imgWallList.add(Util.getMap(jsonObject
									.toString()));

						}
						HomePageView.handler.sendEmptyMessage(0);
					} else {
						HomePageView.imgWall.setVisibility(View.GONE);
					}

				} catch (JSONException e) {
					HomePageView.handler.sendEmptyMessage(1);
					e.printStackTrace();
				}
				super.onSuccess(statusCode, response);
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 5、根据用户id查询用户头像
	public static void getHead(String uid) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		client.post(GET_HEAD, params, new JsonHttpResponseHandler() {
			
			@SuppressWarnings("deprecation")
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					Log.i("HeadImag","获取用户头像"+response.toString());
					if (str != null&&!"".equals(str)) {
						str=POINT+"/"+str;
						Log.i("msg","头像地址"+str);
						spEditor.putString("imgHead", str);
						spEditor.commit();
						//LeftMenuView.headPic.sendEmptyMessage(1);
					} else {
						
					}
				} catch (JSONException e) {
					//HomePageView.handler.sendEmptyMessage(1);
					e.printStackTrace();
				}
				super.onSuccess(statusCode, response);
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 7、删除照片墙的图片
	public static void deleteWall(Context context, String uid, String imgPath) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("id", uid);
		params.put("oldPic", imgPath);
		client.post(DELETE_WALL, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject response) {
				try {
					String str = new JSONObject(response.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						SetHomePageWallActivity.handler.sendEmptyMessage(3);
					}
				} catch (JSONException e) {
					HomePageView.handler.sendEmptyMessage(1);
					e.printStackTrace();
				}
				super.onSuccess(statusCode, response);
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 8查询用户个人资料
	public static void queryMyMaterial(final Context context, final String uid) {
		try {
			client = new AsyncHttpClient();
			params = new RequestParams();
			params.put("uid", uid);
			client.post(QUERY_USER, params, new JsonHttpResponseHandler() {
				@Override
				public void onSuccess(int statusCode, JSONObject jsonObject) {
					try {
						jsonObject = new JSONObject(jsonObject.toString())
								.getJSONObject("response");
						if (jsonObject != null) {
							MyInformationActivity.sexText.setText(jsonObject
									.getString("gender").toString());
							MyInformationActivity.companyText
									.setText(jsonObject.getString("company")
											.toString());
							MyInformationActivity.zhiwuText.setText(jsonObject
									.getString("zhiwu").toString());// 职务
							MyInformationActivity.occupationText
									.setText(jsonObject.getString("occupation")
											.toString());// 行业
							MyInformationActivity.needText.setText(jsonObject
									.getString("requirement").toString());// 需求
							MyInformationActivity.supplyText.setText(jsonObject
									.getString("supply").toString());// 供应
						}

					} catch (JSONException e) {
						// Util.toast(context, "淇℃伅瑙ｆ瀽澶辫触");
						e.printStackTrace();
					} finally {
						try {
							MyInformationActivity.sexText.setText(jsonObject
									.getString("gender").toString());
							MyInformationActivity.companyText
									.setText(jsonObject.getString("company")
											.toString());
							MyInformationActivity.zhiwuText.setText(jsonObject
									.getString("zhiwu").toString());// 职务
							MyInformationActivity.occupationText
									.setText(jsonObject.getString("occupation")
											.toString());// 行业
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
					super.onSuccess(statusCode, jsonObject);
				}

				@Override
				public void onFailure(Throwable e, JSONObject errorResponse) {
					// Util.toast(context, "鏈嶅姟鍣ㄨ繛鎺ュけ璐�);
					// super.onFailure(e, errorResponse);
				}
			});
		} catch (Exception e) {
			// Util.toast(context, "璇锋鏌ユ偍鐨勭綉缁滆繛鎺�);
			e.printStackTrace();
		}
	}

	// 9、修改用户个人信息
	public static void updateMyMaterial(final Context context,
			final String uid, final String sex, final String company,
			final String zhiwu, final String occupation, final String need,
			final String supply) {
		try {
			client = new AsyncHttpClient();
			params = new RequestParams();
			params.put("id", uid);
			params.put("gender", sex);
			params.put("company", company);
			params.put("zhiwu", zhiwu);
			params.put("occupation", occupation);
			params.put("supply", supply);
			params.put("requirement", need);
			client.post(UPDATE_USER, params, new JsonHttpResponseHandler() {
				@Override
				public void onSuccess(int statusCode, JSONObject jsonObject) {
					try {
						String str = new JSONObject(jsonObject.toString())
								.getString("response").trim().toString();
						if (str.equals("true")) {
							MyInformationActivity.handler.sendEmptyMessage(0);
						}
					} catch (JSONException e) {
						Util.toast(context, "信息修改失败");
						e.printStackTrace();
					}
					super.onSuccess(statusCode, jsonObject);
				}

				@Override
				public void onFailure(Throwable e, JSONObject errorResponse) {
					Util.toast(context, "服务器连接失败");
					super.onFailure(e, errorResponse);
				}
			});
		} catch (Exception e) {
			Util.toast(context, "请检查您的网络连接");
			e.printStackTrace();
		}

	}

	// 10、根据用户id查询用户最新的个性签名
	public static void getSignature(final Context context, String uid) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		client.post(GET_SIGNATURE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					HomePageView.myIntroduce = str;
					HomePageView.handler
							.sendEmptyMessage(HomePageView.GET_SIGNATURE);
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 11、更新用户的个性签名
	public static void updateSignature(final Context context, String uid,
			String signatureContent) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("userId", uid);
		params.put("content", signatureContent);
		client.post(UPDATE_SIGNATURE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						HomePageView.handler
								.sendEmptyMessage(HomePageView.UPDATE_SIGNATURE);
					}
				} catch (JSONException e) {
					HomePageView.handler.sendEmptyMessage(1);
					e.printStackTrace();
				}
				super.onSuccess(statusCode, jsonObject);
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 12、根据用户id查询该用户所有分享
	public static void getMyShare(final Context context, String uid, int count) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("count", count + "");
		client.post(GET_MY_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isShare = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();

					if (isShare.equals("share")) {
						String shareContent = new JSONObject(jsonObject
								.toString()).getString("share").trim()
								.toString();
						if (shareContent != null) {
							// json转对象
							Gson gson = new Gson();
							MainService.shareEntity = gson.fromJson(
									shareContent,
									new TypeToken<List<ShareEntity>>() {
									}.getType());
							HomePageView.handler
									.sendEmptyMessage(HomePageView.GET_MY_SHARE_CONTENT);
						}

					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 12-1、根据用户id查询该用户所有分享(更多)
	public static void getMyShareMore(final Context context, String uid,
			int count, int pageSize) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("count", count + "");
		// final List<Map<String,Object>> data = new
		// ArrayList<Map<String,Object>>();
		client.post(GET_MY_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isShare = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (isShare.equals("share")) {
						String shareContent = new JSONObject(jsonObject
								.toString()).getString("share").trim()
								.toString();
						if (shareContent != null) {
							// json转对象
							Gson gson = new Gson();
							HomePageView.moreShareList = gson.fromJson(
									shareContent,
									new TypeToken<List<ShareEntity>>() {
									}.getType());
							HomePageView.handler
									.sendEmptyMessage(HomePageView.GET_MY_MORE_SHARE_CONTENT);
						}
						// JSONArray jsonArray = new JSONArray(shareContent);
						// HomePageView.moreShareList = new
						// ArrayList<Map<String, Object>>();
						// for (int i = 0; i < jsonArray.length(); i++) {
						// JSONObject json = jsonArray.getJSONObject(i);
						// HomePageView.moreShareList.add(Util.getMap(json
						// .toString()));
						// // data.add(Util.getMap(json.toString()));
						// // HomePageView.shareList=data;
						// }
						// HomePageView.handler
						// .sendEmptyMessage(HomePageView.GET_MY_MORE_SHARE_CONTENT);

					}

				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				HomePageView.handler.sendEmptyMessage(1);
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 13、赞过的人
	public static void getPraiseMan(final Context context, String bolgId,
			final String shareType) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("blogid", bolgId);
		client.post(GET_PRAISE_PERSON, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					if ("homeShare".equals(shareType)) {
						// 我的主页--进来
						String personList = new JSONObject(jsonObject
								.toString()).getString("response").trim()
								.toString();
						if ("funsList".equals(personList)) {
							String funsList = new JSONObject(jsonObject
									.toString()).getString("funsList").trim()
									.toString();
							JSONArray jsonArray = new JSONArray(funsList);
							HomePageShareContentActivity.funsList = new ArrayList<Map<String, Object>>();
							for (int i = 0; i < jsonArray.length(); i++) {
								JSONObject json = jsonArray.getJSONObject(i);
								HomePageShareContentActivity.funsList.add(Util
										.getMap(json.toString()));
							}
							HomePageShareContentActivity.handler
									.sendEmptyMessage(HomePageShareContentActivity.FUNS_SUCCESS);
						}
					} else if ("newShare".equals(shareType)) {
						// 最新分享--进来
						String personList = new JSONObject(jsonObject
								.toString()).getString("response").trim()
								.toString();
						if ("funsList".equals(personList)) {
							String funsList = new JSONObject(jsonObject
									.toString()).getString("funsList").trim()
									.toString();
							JSONArray jsonArray = new JSONArray(funsList);
							ShareContentActivity.funsList = new ArrayList<Map<String, Object>>();
							for (int i = 0; i < jsonArray.length(); i++) {
								JSONObject json = jsonArray.getJSONObject(i);
								ShareContentActivity.funsList.add(Util
										.getMap(json.toString()));
							}
							ShareContentActivity.handler
									.sendEmptyMessage(ShareContentActivity.FUNS_SUCCESS);
						}
					} else {
						Util.toast(context, "服务器连接失败");
					}

				} catch (JSONException e) {
					Util.toast(context, "数据加载失败");
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				Util.toast(context, "网络连接有误");
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 14、根据指定分享id查询相应的评论及回复
	public static void lookComment(final Context context, String blogId,
			int count, final String shareType) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("count", count + "");
		params.put("blogid", blogId);
		client.post(LOOK_COMMENT, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					if ("homeShare".equals(shareType)) {
						String isComment = new JSONObject(jsonObject.toString())
								.getString("response").trim().toString();
						if (isComment.equals("comment")) {
							String commentContent = new JSONObject(jsonObject
									.toString()).getString("comment").trim()
									.toString();
							JSONArray jsonArray = new JSONArray(commentContent);
							HomePageShareContentActivity.commentList = new ArrayList<Map<String, Object>>();
							for (int i = 0; i < jsonArray.length(); i++) {
								JSONObject json = jsonArray.getJSONObject(i);
								HomePageShareContentActivity.commentList
										.add(Util.getMap(json.toString()));
							}
							HomePageShareContentActivity.handler
									.sendEmptyMessage(HomePageShareContentActivity.GET_COMMENT_SUCCESS);
						}
					} else if ("newShare".equals(shareType)) {
						String isComment = new JSONObject(jsonObject.toString())
								.getString("response").trim().toString();
						if (isComment.equals("comment")) {
							String commentContent = new JSONObject(jsonObject
									.toString()).getString("comment").trim()
									.toString();
							JSONArray jsonArray = new JSONArray(commentContent);
							ShareContentActivity.commentList = new ArrayList<Map<String, Object>>();
							for (int i = 0; i < jsonArray.length(); i++) {
								JSONObject json = jsonArray.getJSONObject(i);
								ShareContentActivity.commentList.add(Util
										.getMap(json.toString()));
							}
							ShareContentActivity.handler
									.sendEmptyMessage(ShareContentActivity.GET_COMMENT_SUCCESS);
						}
					} else {
						Util.toast(context, "服务器连接失败");
					}

				} catch (JSONException e) {
					Util.toast(context, "数据加载失败");
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				Util.toast(context, "网络连接有误");
				super.onFailure(e, errorResponse);
			}
		});
	}

	/**
	 * 15、增加回复
	 * 
	 * @param userId
	 *            用户id
	 * @param toId
	 *            接受者id
	 * @param bolgId
	 *            分享的id
	 * @param content
	 *            回复的内容
	 * @param parentId
	 *            评论的id
	 */
	public static void addReply(final Context context, String userId,
			String toId, String bolgId, String content, String parentId,
			final String shareType,final String typeId) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("userid", userId);
		params.put("toId", toId);
		params.put("blogId", bolgId);
		params.put("content", content);
		params.put("parentId", parentId);
		params.put("typeId", typeId);//为0是个人的，否则为圈子的id
		// http://192.168.1.108:8080/huashangService/addReply?userid=123&toId=123&blogId=2&content=It's_me,I_am_ailon&parentId=1
		client.post(ADD_REPLY, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {

				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						if("0".equals(typeId)){
							if ("homeShare".equals(shareType)) {
								HomePageShareContentActivity.handler
										.sendEmptyMessage(HomePageShareContentActivity.ADD_REPLY_SUCCESS);
							} else if ("newShare".equals(shareType)) {
								ShareContentActivity.handler
										.sendEmptyMessage(ShareContentActivity.ADD_REPLY_SUCCESS);
							} else {
								Util.toast(context, "服务器连接失败");
							}
						}else{
							CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.ADD_REPLY_SUCCESS);
						}
						
					}
				} catch (JSONException e) {
					Util.toast(context, "数据加载失败");
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				Util.toast(context, "网络连接有误");
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 16、最新分享（最新推荐）-----乐分享（最新分享）
	public static void getNewShare(int count, final String isRefresh) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("count", count + "");
		client.post(GET_NEW_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isShare = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (isShare.equals("newestShare")) {
						String new_shareContent = new JSONObject(jsonObject
								.toString()).getString("newestShare").trim()
								.toString();

						// json转对象
						Gson gson = new Gson();
						MainService.newShareEntity = gson.fromJson(
								new_shareContent,
								new TypeToken<List<ShareEntity>>() {
								}.getType());
						if ("load".equals(isRefresh)) {
							Item05View.handler
									.sendEmptyMessage(Item05View.SUCCESS);
						} else {
							Item05View.handler
									.sendEmptyMessage(Item05View.REFERSH);
						}

					}

				} catch (JSONException e) {
					Item05View.handler.sendEmptyMessage(Item05View.FAIL);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				Item05View.handler.sendEmptyMessage(Item05View.FAIL);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 16、最新分享（最新推荐）-----乐分享（最新分享）---更多
	public static void getNewShareMore(int count) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("count", count + "");
		client.post(GET_NEW_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isShare = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (isShare.equals("newestShare")) {
						String new_shareContent = new JSONObject(jsonObject
								.toString()).getString("newestShare").trim()
								.toString();

						// json转对象
						Gson gson = new Gson();
						Item05View.moreShareList = gson.fromJson(
								new_shareContent,
								new TypeToken<List<ShareEntity>>() {
								}.getType());

						Item05View.handler
								.sendEmptyMessage(Item05View.GET_MORE_NEW_SHARE);
					}

				} catch (JSONException e) {
					Item05View.handler.sendEmptyMessage(Item05View.FAIL);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				Item05View.handler.sendEmptyMessage(Item05View.FAIL);
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 17、增加赞
	public static void addPraise(String uid, String toId, String blogId,
			final String praiseType,final String circleId) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("userid", uid);
		params.put("toid", toId);
		params.put("blogid", blogId);// blogid 小写
		if(null!=circleId||!"".equals(circleId)){
			params.put("circleid", circleId);
		}
		client.post(ADD_PRAISE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						if(null!=circleId||!"".equals(circleId)){
							CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.ADD_PRAISE_SUCCESS);
						}else{
							if ("item05".equals(praiseType)) {
								Item05View.handler
										.sendEmptyMessage(Item05View.ADD_PRAISE_SUCCESS);
							} else if ("shareContent".equals(praiseType)) {
								// ADD_COMMENT_SUCCESS
								ShareContentActivity.handler
										.sendEmptyMessage(ShareContentActivity.ADD_PRAISE_SUCCESS);
							}
						}
						

					}
				} catch (JSONException e) {
					if(null!=circleId||!"".equals(circleId)){
						CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.FAIL);
					}else{
						if ("item05".equals(praiseType)) {
							Item05View.handler.sendEmptyMessage(Item05View.FAIL);
						} else if ("shareContent".equals(praiseType)) {
							// ADD_COMMENT_SUCCESS
							ShareContentActivity.handler
									.sendEmptyMessage(ShareContentActivity.FAIL);
						}
					}
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				if(null!=circleId||!"".equals(circleId)){
					CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.FAIL);
				}else{

					if ("item05".equals(praiseType)) {
						Item05View.handler.sendEmptyMessage(Item05View.FAIL);
					} else if ("shareContent".equals(praiseType)) {
						// ADD_COMMENT_SUCCESS
						ShareContentActivity.handler
								.sendEmptyMessage(ShareContentActivity.FAIL);
					}
				}
				super.onFailure(e, errorResponse);
			}

		});
	}

	// 18、增加评论
	public static void addComment(String uid, String toId, String blogId,
			String content, final String typeId, final String commentType) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("userid", uid);
		params.put("toid", toId);
		params.put("blogId", blogId);// blogId 大写
		params.put("content", content);
		params.put("typeId", typeId);//为0时默认为个人分享的评论，为1时是圈子分享的评论
		client.post(ADD_COMMENT, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						if("0".equals(typeId)){
							if ("item05".equals(commentType)) {
								Item05View.handler
										.sendEmptyMessage(Item05View.ADD_COMMENTE_SUCCESS);
							} else if ("shareContent".equals(commentType)) {
								// ADD_COMMENT_SUCCESS
								ShareContentActivity.handler
										.sendEmptyMessage(ShareContentActivity.ADD_COMMENT_SUCCESS);
							}
						}else if("1".equals(typeId)){
							CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.ADD_COMMENT_SUCCESS);
						}
						

					}
				} catch (JSONException e) {
					if("1".equals(typeId)){
						CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.FAIL);
					}else if("0".equals(typeId)){
						if ("item05".equals(commentType)) {
							Item05View.handler.sendEmptyMessage(Item05View.FAIL);
						} else if ("shareContent".equals(commentType)) {
							// ADD_COMMENT_SUCCESS
							ShareContentActivity.handler
									.sendEmptyMessage(ShareContentActivity.FAIL);
						}
					}
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				if("1".equals(typeId)){
					CircleShareContentActivity.handler.sendEmptyMessage(CircleShareContentActivity.FAIL);
				}else if("0".equals(typeId)){
					if ("item05".equals(commentType)) {
						Item05View.handler.sendEmptyMessage(Item05View.FAIL);
					} else if ("shareContent".equals(commentType)) {
						// ADD_COMMENT_SUCCESS
						ShareContentActivity.handler
								.sendEmptyMessage(ShareContentActivity.FAIL);
					}
				}
				super.onFailure(e, errorResponse);
			}

		});
	}

	// 19、上传发表分享的图片
	public static void uploadSharePicture(final Context context, String imgPath)
			throws FileNotFoundException {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("upload", new File(imgPath));
		client.post(UPLOAD_SHARE_PICTURE, params,
				new JsonHttpResponseHandler() {
					@Override
					public void onSuccess(int statusCode, JSONObject jsonObject) {
						try {
							String str = new JSONObject(jsonObject.toString())
									.getString("response").trim().toString();
							HSApplication.uploadTempImgList.add(str);
							Util.toast(context, "图片上传成功");
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					@Override
					public void onFailure(Throwable e, JSONObject errorResponse) {
						Util.toast(context, "图片上传失败");
						super.onFailure(e, errorResponse);
					}
				});
	}

	// 20、删除 上传发表分享的图片
	public static void deleteSharePicture(final Context context, String sharePic) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("sharePic", sharePic);
		client.post(DELETE_SHARE_PICTURE, params,
				new JsonHttpResponseHandler() {
					@Override
					public void onSuccess(int statusCode, JSONObject jsonObject) {
						try {
							String str = new JSONObject(jsonObject.toString())
									.getString("response").trim().toString();
							if ("true".equals(str)) {
								PublishShareActivity.handler
										.sendEmptyMessage(PublishShareActivity.DELETE_SHARE_PIC_SUCCESS);
							} else {
								Util.toast(context, "图片删除失败");
							}
						} catch (JSONException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}

					@Override
					public void onFailure(Throwable e, JSONObject errorResponse) {
						Util.toast(context, "图片删除失败");
						super.onFailure(e, errorResponse);
					}
				});

	}

	// 21、增加原创分享
	public static void addShare(final Context context, String uid,
			String nickName, String txt, String location, String atPerson,
			String pic) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("nickname", nickName);
		params.put("txt", txt);
		params.put("location", location);
		params.put("idList", atPerson);
		params.put("picList", pic);

		client.post(ADD_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						PublishShareActivity.handler
								.sendEmptyMessage(PublishShareActivity.ADD_SHARE_SUCCESS);
						Util.toast(context, "发表成功");
					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				PublishShareActivity.handler
						.sendEmptyMessage(PublishShareActivity.FAIL);
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 22、增加推荐2级
	public static void addShare2(final Context context, String uid,
			String shareId, String title, String name) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("shareid", shareId);
		params.put("title", title);
		params.put("name", name);
		client.post(ADD_FORWARD_SHARE2, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						ShareContentActivity.handler
								.sendEmptyMessage(ShareContentActivity.ADD_FORWARD_SHARE2);
						// Util.toast(context, "转发成功");
					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				ShareContentActivity.handler
						.sendEmptyMessage(ShareContentActivity.FAIL);// 和转发2级公用一个
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 23、增加推荐3级
	public static void addShare3(final Context context, String uid,
			String shareId, String title, String name) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("shareid", shareId);
		params.put("title", title);
		params.put("name", name);
		client.post(ADD_FORWARD_SHARE3, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						ShareContentActivity.handler
								.sendEmptyMessage(ShareContentActivity.ADD_FORWARD_SHARE2);// 和转发2级公用一个
						// Util.toast(context, "转发成功");
					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				ShareContentActivity.handler
						.sendEmptyMessage(ShareContentActivity.FAIL);// 和转发2级公用一个
				super.onFailure(e, errorResponse);
			}
		});
	}

	// 24、查询指定圈子分享
	public static void getCircleShare(String circleId, int count) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("circleId", circleId);
		params.put("count", count + "");
		client.post(SELECT_CIRCLE_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isShare = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (isShare.equals("newestCircleShare")) {
						String new_shareContent = new JSONObject(jsonObject
								.toString()).getString("newestCircleShare")
								.trim().toString();

						// json转对象
						Gson gson = new Gson();
						CircleHomeActivity.circleShareEntity = new ArrayList<CircleShareEntity>();
						CircleHomeActivity.circleShareEntity = gson.fromJson(
								new_shareContent,
								new TypeToken<List<CircleShareEntity>>() {
								}.getType());

						CircleHomeActivity.handler
								.sendEmptyMessage(CircleHomeActivity.SUCCESS);
					}

				} catch (JSONException e) {
					CircleHomeActivity.handler
							.sendEmptyMessage(CircleHomeActivity.FAIL);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				CircleHomeActivity.handler
						.sendEmptyMessage(CircleHomeActivity.FAIL);
			}
		});

	}

	// 25、增加圈子分享
	public static void addCircleShare(final Context context, String uid,
			String nickName, String circleId, String txt, String atPerson,// String
																			// location,
			String pic) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("uid", uid);
		params.put("nickName", nickName);
		params.put("circleId", circleId);
		params.put("txt", txt);
		// params.put("location", location);
		params.put("idList", atPerson);
		params.put("picList", pic);

		client.post(ADD_CIRCLE_SHARE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String str = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if (str.equals("true")) {
						PublishCircleShareActivity.handler
								.sendEmptyMessage(PublishCircleShareActivity.ADD_SHARE_SUCCESS);
						Util.toast(context, "发表成功");
					}
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				PublishCircleShareActivity.handler
						.sendEmptyMessage(PublishCircleShareActivity.FAIL);
				super.onFailure(e, errorResponse);
			}
		});

	}

	// 26、根据指定分享id查询相应的 圈子的 评论及回复
	public static void lookCircleComment(String blogId, String circleId,
			int count) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("blogid", blogId);
		params.put("circleId", circleId);
		params.put("count", count + "");
		client.post(LOOK_CIRCLE_COMMENT, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {

//					String isComment = new JSONObject(jsonObject.toString())
//							.getString("response").trim().toString();
					// if (isComment.equals("comment")) {
					if (jsonObject.has("comment")) {

						String commentContent = new JSONObject(jsonObject
								.toString()).getString("comment").trim()
								.toString();
						JSONArray jsonArray = new JSONArray(commentContent);
						CircleShareContentActivity.commentList = new ArrayList<Map<String, Object>>();
						for (int i = 0; i < jsonArray.length(); i++) {
							JSONObject json = jsonArray.getJSONObject(i);
							CircleShareContentActivity.commentList.add(Util
									.getMap(json.toString()));
						}
						CircleShareContentActivity.handler
								.sendEmptyMessage(CircleShareContentActivity.GET_COMMENT_SUCCESS);

					}

					if (jsonObject.has("funsList")) {

						String commentContent = new JSONObject(jsonObject
								.toString()).getString("funsList").trim()
								.toString();
						JSONArray jsonArray = new JSONArray(commentContent);
						CircleShareContentActivity.funsList = new ArrayList<Map<String, Object>>();
						for (int i = 0; i < jsonArray.length(); i++) {
							JSONObject json = jsonArray.getJSONObject(i);
							CircleShareContentActivity.funsList.add(Util
									.getMap(json.toString()));
						}
						CircleShareContentActivity.handler
								.sendEmptyMessage(CircleShareContentActivity.FUNS_SUCCESS);

					}
					// }
				} catch (JSONException e) {

					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {

			}
		});
	}

	// 27、申请加入圈子
	public static void waitJoin(String circleId, String uid,
			final String isWaiting) {
		client = new AsyncHttpClient();
		params = new RequestParams();
		params.put("typeId", circleId);
		params.put("userId", uid);
		client.post(WAIT_JOIN_CIRCLE, params, new JsonHttpResponseHandler() {
			@Override
			public void onSuccess(int statusCode, JSONObject jsonObject) {
				try {
					String isJoin = new JSONObject(jsonObject.toString())
							.getString("response").trim().toString();
					if ("true".equals(isJoin)) {
						if ("1".equals(isWaiting)) {// 1:自由加入
							CircleHomeActivity.handler
									.sendEmptyMessage(CircleHomeActivity.JOIN_SUCCESS);
						} else if ("0".equals(isWaiting)) {// 0：需要申请
							CircleHomeActivity.handler
									.sendEmptyMessage(CircleHomeActivity.JOIN_WAIT);
						} else {// 100：禁止加入
							CircleHomeActivity.handler
									.sendEmptyMessage(CircleHomeActivity.JOIN_FAIL);
						}
					}
				} catch (JSONException e) {
					CircleHomeActivity.handler
							.sendEmptyMessage(CircleHomeActivity.FAIL);
					e.printStackTrace();
				}
			}

			@Override
			public void onFailure(Throwable e, JSONObject errorResponse) {
				CircleHomeActivity.handler
						.sendEmptyMessage(CircleHomeActivity.FAIL);
			}
		});
	}

}
